<table id="manage_wayInfo" data-options="fit:true"></table>
<script>
$(function(){
	$('#manage_wayInfo').datagrid({
		url:'../json/WayInfo_getWayInfoList',
		loadMsg:'数据加载中...',
		fitColumns:true,
		rownumbers:true,
		striped:true,
		sortName:'wid',
		sortOrder:'asc',
		remoteSort:false,
		columns:[[
			{field:'wids',title:'',width:30,align:'center',checkbox:true},
			{field:'wid',title:'编号',width:30,align:'center',sortable:true},
			{field:'wtime',title:'花费时间',width:50,align:'center'}, 
			{field:'wcost',title:'经费',width:50,align:'center'},
			{field:'wway',title:'线路',width:400,align:'center'},
		]],
		toolbar: [{
			iconCls: 'icon-add',
			text:'添加',
			handler: function(){
				$("#add_wayInfo").dialog("open");
			}
		},'-',{
			iconCls: 'icon-remove',
			text:'删除',
			handler: function(){
				alert('help')
			}
		}]
	});
});

function addAgencyInfo(){
	var wtime=$("#way_wtime").val();
	var wcost=$("#way_wcost").val();
	var wway=$("#way_wway").val();
	$.ajax({
	    url: "../json/WayInfo_addWayInfo",    //请求的url地址
	    dataType: "json",   //返回格式为json
	    async: true, //请求是否异步，默认为异步，这也是ajax重要特性
	    type: "POST",
	    data:{
	    	"wtime":wtime,
	    	"wcost":wcost,
	    	"wway":wway
	    },
	    success: function(data) {
	    	if(parseInt($.trim(data.obj))>=1){
	    		$.messager.show({
					title:'成功提示',
					msg:'添加信息成功！',
					timeout:3000,
					showType:'slide'
				});
	    		$("#add_wayInfo").dialog("close");
	    		$("#way_wtime").val("");
	    		$("#way_wcost").val("");
	    		$("#way_wway").val("");
				$('#manage_wayInfo').datagrid("reload");
	    	}else{
	    		$.messager.alert('错误提示','添加信息失败,请稍后重试!','error');
	    	}
	    }
	});
}

</script>
<div id="add_wayInfo" class="easyui-dialog" title="添加旅游线路" style="width:400px;height:230px;"
	data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true">
	<div style="margin-left: 15px;">
		<br /> <br /> 
		<label for="way_wtime">花费时间：</label><input type="text" id="way_wtime">
		<label for="way_wcost">经费：</label><input type="text" id="way_wcost">
		<br/><br/>
		<label for="way_wway" style="vertical-align: top">线路：</label><textarea rows="2" cols="50" id="way_wway"></textarea>
		<br/><br/>
		<center><input style="padding:5px 25px;" type="button" onclick="addAgencyInfo()" value="添加"></center>
	</div>
</div>